package resource.manager.classes;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class FilesManager {

	public boolean writeToFile(String filename){
		ObjectOutputStream  objectOut = null;
	     try
	     {
	      File file = new File("sdcard/" + "ResourcesManager");
	      if(!file.exists() && file.mkdir())
	   {
	       file = new File(filename);
	       if(!file.exists())
	        file.createNewFile();
	   }

	      FileOutputStream stream = new FileOutputStream(filename);
	      objectOut = new ObjectOutputStream(new BufferedOutputStream(stream));
	      objectOut.writeObject("message");

	      return true;
	     }
	     catch(IOException e)
	     {
	      e.printStackTrace();
	      return false;
	     }
	     finally
	     {
	      try
	      {
	          if(objectOut != null)
	              objectOut.close();
	      }
	         catch(IOException ex)
	         {
	          ex.printStackTrace();
	         }
	     }

	}
}
